package com.example.cofeed.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.cofeed.R;
import com.example.cofeed.entity.Article;
import com.example.cofeed.util.TempTimeUtils;

import java.util.List;

public class SearchAdapter extends BaseQuickAdapter<Article, BaseViewHolder> {
    public SearchAdapter() {
        super(R.layout.adapter_search);
    }

    @Override
    protected void convert(BaseViewHolder helper, Article item) {
        helper.setText(R.id.tv_sub_title, TempTimeUtils.getFriendlyTimeSpanByNow(item.addtime));
        String title = getTitle(item.title);
        helper.setText(R.id.tv_title, title);

    }

    private String getTitle(String Content){
        Content = Content.replace("&quot;", "\"\"");
        Content=Content.replace("&acute;", "'");
        Content=Content.replace("&sbquo;", ",");
        Content=Content.replace("&lt;", "<");
        Content=Content.replace("&gt;", ">");
        Content=Content.replace("&#37;", "%");
        Content=Content.replace("&#42;", "*");
        Content=Content.replace("&#43;", "+");
        Content=Content.replace("&#61;", "=");
        Content=Content.replace("&#92;", "\\");
        Content=Content.replace("&#40;", "(");
        Content=Content.replace("&#41;", ")");
        Content=Content.replace("&#123;", "{");
        Content=Content.replace("&#125;", "}");
        Content=Content.replace("&#124;", "|");
        Content=Content.replace("&#63;", "?");
        Content=Content.replace("&xp_cmdshell&;", "xp_cmdshell");
        Content=Content.replace("&net&;", "net");
        Content=Content.replace("&administrators&;", "administrators");
        Content=Content.replace("&select&;", "select");
        Content=Content.replace("&count&;", "count");
        Content=Content.replace("&asc&;", " asc ");
        Content=Content.replace("&char&;", "char");
        Content=Content.replace("&mid&;", "mid");
        Content=Content.replace("&insert&;", "insert");
        Content=Content.replace("&delete&;", "delete");
        Content=Content.replace("&drop&;", "drop");
        Content=Content.replace("&truncate&;", "truncate");
        Content=Content.replace("&update&;", "update");
        Content=Content.replace("&exec&;", "exec");
        Content=Content.replace("&master&;", "master");
        Content=Content.replace("&truncate&;", "truncate");
        Content=Content.replace("&.js&;", ".js");
        Content=Content.replace("&<script&;", "<script");

        return Content;

    }

}
